package com.qinglei.recoup.longconn.config;

import com.qinglei.recoup.common.domain.CommonConstant;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author: 最爱学英语的cxd
 * @slogan: 一入代码深似海，从此红尘是路人
 * @create: 2022-03-18
 **/
@Configuration
public class RabbitMqTopiConfig implements BeanPostProcessor {


    @Bean
    public TopicExchange topicExchange(){
        return new TopicExchange(CommonConstant.MQ_DASHBOARD_RECOUP_DIRECT_EXCHANGE);
    }

    @Bean
    public Queue topicDashBoardQueue() {
        return new Queue(CommonConstant.MQ_DASHBOARD_RADAR_DATA_QUEUE);
    }

    @Bean
    public Binding topicExchangeBindQueue(){
        return BindingBuilder.bind(topicDashBoardQueue()).to(topicExchange()).with(CommonConstant.MQ_RADAR_DATA_TOPIC_ROUTING_KEY);
    }

}
